import { InputQuestion, QuestionBase, SelectQuestion, TableBase, TextTable, TimeQuestion } from '@/components/public-template';
import { Api } from '@/config/api/logManage';
import { regExp } from '@/utils/regExp';

class HomeService {
  getQuestions() {
    const questions: QuestionBase<any>[] = [
      new InputQuestion({
        key: 'filesBoxCode',
        label: '档案编码',
        placeholder: '请输入',
        reg: regExp.strLen20,
        prompt: '输入字符需小于20'
        // type: 'search',
        // state: {
        //   mode: '-',
        //   url: Api.page,
        //   protType: 'post',
        //   params: { pageNumber: 1, pageSize: 50 },
        //   nameKey: 'filesBoxCode',
        //   nameValue: 'filesBoxCode'
        // }
      }),
      new InputQuestion({
        key: 'name',
        label: '文件名称',
        placeholder: '请输入',
        reg: regExp.len100,
        prompt: '输入字符需小于100'
        // type: 'search',
        // state: {
        //   mode: '-',
        //   url: Api.page,
        //   protType: 'post',
        //   params: { pageNumber: 1, pageSize: 50 },
        //   nameKey: 'name',
        //   nameValue: 'name'
        // }
      }),
      new InputQuestion({
        key: 'code',
        label: '文件编码',
        placeholder: '请输入',
        reg: regExp.strLen20,
        prompt: '输入字符需小于20'
        // type: 'search',
        // state: {
        //   mode: '-',
        //   url: Api.page,
        //   protType: 'post',
        //   params: { pageNumber: 1, pageSize: 50 },
        //   nameKey: 'code',
        //   nameValue: 'code'
        // }
      }),
      new TimeQuestion({
        label: '创建时间',
        state: {
          keySplit: ['createStartTime', 'createEndTime'],
          format: 'YYYY-MM-DD HH:mm:ss',
          valueFormat: 'YYYY-MM-DD HH:mm:ss'
        }
      }),
      new TimeQuestion({
        label: '修改时间',
        state: {
          keySplit: ['updateStartTime', 'updateEndTime'],
          format: 'YYYY-MM-DD HH:mm:ss',
          valueFormat: 'YYYY-MM-DD HH:mm:ss'
        }
      })
    ];
    return questions;
  }

  getTables() {
    const tables: TableBase<any>[] = [
      new TextTable({
        value: '序号',
        type: 'index'
      }),
      new TextTable({
        key: 'filesBoxCode',
        value: '档案编码'
      }),
      new TextTable({
        key: 'name',
        value: '文件名称'
      }),
      new TextTable({
        key: 'code',
        value: '文件编码'
      }),
      new TextTable({
        key: 'filesTypeName',
        value: '档案类型'
      }),
      new TextTable({
        key: 'dueDateName',
        value: '到期日期'
      }),
      new TextTable({
        key: 'creatorName',
        value: '创建人'
      }),
      new TextTable({
        key: 'createdTime',
        value: '创建时间'
      }),
      new TextTable({
        key: 'modifierName',
        value: '修改人'
      }),
      new TextTable({
        key: 'modifiedTime',
        value: '修改时间'
      }),
      new TextTable({
        key: 'actions',
        value: '操作',
        columns: {
          fixed: 'right'
        },
        handle: [
          {
            type: 'local',
            text: '预览',
            class: 'text-primary',
            params: [{ id: 'id' }],
            state: {}
          }
        ]
      })
    ];
    return tables;
  }
}

export default new HomeService();
